/*-----------------------------------------------------------------------
|                            FILE DESCRIPTION                           |
-----------------------------------------------------------------------*/
/*----------------------------------------------------------------------
  - File name     : Debug.h
  - Author        : liuzhihua
  - Update date   : 2022.5.3                  
  -	File Function : Debug Tools
-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------
|                               UPDATE NOTE                             |
-----------------------------------------------------------------------*/
/**
  * Update note:
  * ------------   ---------------   ----------------------------------
  *     Date            Author                       Note
  * ------------   ---------------   ----------------------------------
  *   2022.5.3        liuzhihua                   Create file
***/

#ifndef __DEBUG_H_
#define __DEBUG_H_

#ifdef  __cplusplus
    extern "C" {
#endif
/*-----------------------------------------------------------------------
|                               INCLUDES                                |
-----------------------------------------------------------------------*/
//#include "zh_main.h"
#include "stdio.h"
#include "stdint.h"
#include "string.h"
#include "board_base.h"
#include "bsp_uart.h"
/*-----------------------------------------------------------------------
|                                DEFINES                                |
-----------------------------------------------------------------------*/


#define DEBUG_UART_PORT huart2
#define __DEBUG__
#ifdef __DEBUG__  
#define DEBUG(format,...) UARTx_Printf((&DEBUG_UART_PORT), (format), ##__VA_ARGS__)
#define DEBUGS(string) UARTx_Print((&DEBUG_UART_PORT),string)
#define DEBUGLINE(format,...) UARTx_Printf(&DEBUG_UART_PORT,"File: "__FILE__", Line: %05d: "format"\n\r", __LINE__, ##__VA_ARGS__)   
#define RTT_Log(format,...) SEGGER_RTT_printf(0, (format), ##__VA_ARGS__);
#define RTT_Logs(string) SEGGER_RTT_WriteString(0, string)
#else  
#define DEBUG(format,...)
#define DEBUGS(string)
#define DEBUGLINE(format,...)  
#define RTT_Log(format,...) 
#define RTT_Logs(string) 
#endif 

enum ImgFormat {
    Format_Invalid,
    Format_Mono,
    Format_MonoLSB,
    Format_Indexed8,
    Format_RGB32,
    Format_ARGB32,
    Format_ARGB32_Premultiplied,
    Format_RGB16,//RGB-565
    Format_ARGB8565_Premultiplied,
    Format_RGB666,
    Format_ARGB6666_Premultiplied,
    Format_RGB555,
    Format_ARGB8555_Premultiplied,
    Format_RGB888,
    Format_RGB444,
    Format_ARGB4444_Premultiplied,
    Format_RGBX8888,
    Format_RGBA8888,
    Format_RGBA8888_Premultiplied,
    Format_BGR30,
    Format_A2BGR30_Premultiplied,
    Format_RGB30,
    Format_A2RGB30_Premultiplied,
    Format_Alpha8,
    Format_Grayscale8,
    
    // 以下格式发送时，IMG_WIDTH和IMG_HEIGHT不需要强制指定，设置为-1即可
    Format_BMP,
    Format_GIF,
    Format_JPG,
    Format_PNG,
    Format_PBM,
    Format_PGM,
    Format_PPM,
    Format_XBM,
    Format_XPM,
    Format_SVG,
};
// 先发送前导帧
//int preFrame[7] = {
//    IMG_ID, 
//    IMG_SIZE, 
//    IMG_WIDTH, 
//    IMG_HEIGHT, 
//    IMG_FORMAT, 
//    0x7F800000, 
//    0x7F800000
//};
#define OV7725IMG "image:1,28800,120,120,7\n"//Format_RGB16

#define VOFAHUART huart1
extern   UART_HandleTypeDef VOFAHUART;
#define Vofa_Printf(pbuf,...) 		UARTx_Printf(&VOFAHUART,(const char*)pbuf,##__VA_ARGS__)
#define Vofa_Send_Data(pbuf,len) 	UARTx_Printf(&VOFAHUART,(const char*)pbuf)//HAL_UART_Transmit(HUART,(uint8_t*)pbuf,len,0xFF);
#define Vofa_DMA_Send(pbuf,len)		HAL_UART_Transmit_DMA(&VOFAHUART,(uint8_t*)pbuf,len)

#define VofaDataFormat(name,format,...) name ":" format "\n\r", ##__VA_ARGS__
#define Vofa_Draw(name,format,...) \
Vofa_Printf(name ":" format "\n\r", ##__VA_ARGS__) 
		

/*-----------------------------------------------------------------------
|                             API FUNCTION                              |
-----------------------------------------------------------------------*/
void Vofa_Send_Graph(char* preFrame,uint8_t* imgbuf,size_t size);


#ifdef __cplusplus
}
#endif

#endif

